/**
 * @(#)RabbitMQTopicProducer.java, 2018/12/17
 * <p/>
 * Copyright 2018 Netease, Inc. All rights reserved.
 * NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.chengzhi.mq;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author 阮承志(wb.ruanchengzhi @ mesg.corp.netease.com)
 **/
public class RabbitMQTopicProducer {

    public static void main(String[] args) throws IOException, InterruptedException, TimeoutException {
        Connection connection = RabbitMQConstants.getConnection();
        Channel channel = connection.createChannel();
        AMQP.BasicProperties properties = new AMQP.BasicProperties.Builder().deliveryMode(2)
                .expiration("6000")
                .build();
        for (int i = 0; i < 10; i++) {
            channel.basicPublish("topic-exchange", "topicKey.two", properties, ("topic-test -----" + i).getBytes());
        }
        channel.close();
        connection.close();
    }
}
